﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DbViewDriver
{
	// class for configuring a menu of extension/customised commands
	//
	// Non form objects to pass to a window system (winforms or WPF)
	// Same concepts menus, items, separators.
	// 
	// 
	public class CustomMenuItem
	{
		// here's your type
		// menu is a collection of items 
		// item should have unique tag value to indicate which custom command command it represents
		// separator hints to the UI to separate items
		public enum ItemType {menu, item, separator}
		
		//
		// while in transition the tag may be just the command name eg Tables or
		// and Xml command with actions and parameters.
		// The intention in the future is to change to attach real commands.
		// 
		public CustomMenuItem(ItemType type, String name, String commandTag)
		{
			this.type = type;
			this.name = name;
			this.tag = commandTag;
			this.IsRowIndependent = false;
			if (type == ItemType.menu) this.items = new List<CustomMenuItem>();
		}
		public CustomMenuItem(ItemType type) : this(type,"", "") {}
		public CustomMenuItem(ItemType type, String name) : this(type, name, "") {}
		public String Name {get { return this.name; } }
		public String CommandTag { get { return this.tag; } }
		public String Help { get { return this.help; } set { this.help = value; }}
		public ItemType Type { get { return this.type; } }
		public bool IsRowIndependent {get; set;}
		public List<CustomMenuItem> Items {get {return this.items; }} 

		public void AddItem(CustomMenuItem item)
		{
			if (this.Type != ItemType.menu) throw new Exception("Cannot add items type a non-menu type menu item");
			this.Items.Add(item);
		}
		
		ItemType type;
		String name = "";
		String tag = "";
		String help = "";
		List<CustomMenuItem> items = null;
	}
}
